﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace NeuroForecast
{
    /// <summary>
    /// Interaction logic for CreateAlgorithm.xaml
    /// </summary>
    public partial class CreateAlgorithm : Window
    {
        #region EventDefinition
        public delegate void CreatingAlgorithmEventHandler(object sender, CreatingAlgorithmEventArgs e);

        public event CreatingAlgorithmEventHandler CreatingAlgorithmEvent;

        public class CreatingAlgorithmEventArgs : EventArgs
        {
            public String AlgorithmName { set; get; }
            public SourceListItem SelectedCriterion { set; get; }
            public DateTime DateStart { set; get; }
            public DateTime DateEnd { set; get; }

            public CreatingAlgorithmEventArgs(String name, SourceListItem selectedCriterion, DateTime dateStart, DateTime dateEnd)
            {
                AlgorithmName = name;
                SelectedCriterion = selectedCriterion;
                DateStart = dateStart;
                DateEnd = dateEnd;
            }
        }

        public virtual void RaiseCreatingAlgorithmEvent(String name, SourceListItem selectedCriterion, DateTime dateStart, DateTime dateEnd)
        {
            if (CreatingAlgorithmEvent != null)
            {
                CreatingAlgorithmEvent(this, new CreatingAlgorithmEventArgs(name, selectedCriterion, dateStart, dateEnd));
            }
        }
        #endregion

        public MainWindow MainWindow { set; get; }

        public CreateAlgorithm()
        {
            InitializeComponent();
        }

        private void but_Cancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void but_Ok_Click(object sender, RoutedEventArgs e)
        {
            Close();
            RaiseCreatingAlgorithmEvent(tb_AlgorithmName.Text, (SourceListItem)MainWindow.SourceList.Items[0], new DateTime(2010,12,01), new DateTime(2010,12,31) );
        }

        private void but_Ok_Click_1(object sender, RoutedEventArgs e)
        {

        }
    }
}
